<?php

namespace backend\models\system;
use backend\models\system\Banner;
use Yii;

/**
 * This is the model class for table "edu_banner_group".
 *
 * @property integer $group_id
 * @property integer $group_isshow
 * @property string $group_desc
 * @property integer $group_addtime
 * @property integer $group_sort
 */
class BannerGroup extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'edu_banner_group';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['group_isshow', 'group_addtime', 'group_sort'], 'integer'],
            [['group_desc'], 'required'],
	        [['group_sort'], 'unique'],
            [['group_desc'], 'string', 'max' => 100]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'group_id' => 'Group ID',
            'group_isshow' => '是否显示',
            'group_desc' => '轮播组描述',
            'group_addtime' => 'Group Addtime',
            'group_sort' => '轮播组排序',
        ];
    }

    /**
     * 轮播列表查询
     */
    public function getBanner()
    {
        //return $this->find()->asarray()->all();
        return $this->hasMany(Banner::className(), ['group_id'=>'group_id'])->asarray();
    }

	/**
	 * 轮播列表查询
	 * 状态为  1   开启状态
	 */
	public function getBanneropen()
	{
		return $this->hasMany(Banner::className(),['group_id'=>'group_id']);
	}
}
